<script setup lang="ts">
const el = ref(null)
const show = ref(false)
useIntersectionObserver(el, ([{ isIntersecting }]) => {
  if (isIntersecting)
    show.value = isIntersecting
})

const list = ref([
  {
    img: 'https://public-oss-file.zmaxfilm.com/website-compress/join-8.png',
    title: '中瑞剧坊办公区',
  }, {
    img: 'https://public-oss-file.zmaxfilm.com/website-compress/join-9.png',
    title: '中瑞剧坊办公休息区',
  }, {
    img: 'https://public-oss-file.zmaxfilm.com/website-compress/join-10.png',
    title: '月星影城办公区',
  },
])
function onEnter(el: any, done: any) {
  el.style.opacity = 0
  const delay = el.dataset.index * 100
  const animation = 'fadeInRight 0.8s infinite'
  setTimeout(() => {
    el.style.transition = 'opacity 0.8s '
    el.style.opacity = 1
    el.style.animation = animation
    el.style['animation-iteration-count'] = 1
    done()
  }, delay)
}
</script>

<template>
  <div id="bghj" ref="el" class="zhaopinliucheng">
    <Transition name="animate-zoomIn">
      <h1 v-show="show" class="line-center-title">
        办公环境
      </h1>
    </Transition>
    <div class="list">
      <transition-group @enter="onEnter">
        <div v-for="(item, index) in list" v-show="show" :key="index" class="card" :data-index="index">
          <img class="img" :src="item.img">
          <span class="title">{{ item.title }}</span>
        </div>
      </transition-group>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.zhaopinliucheng {
  width: 1200px;
  margin: 0 auto;
  min-height: 600px;
  padding-bottom: 80px;

  .line-center-title {
    font-family: PangMenZhengDaoBiaoTiTi;
    margin-bottom: 40px;
  }

  .list {
    gap: 20px;
    display: flex;

    .card {
      flex: 1;
      display: flex;
      align-items: center;
      flex-direction: column;

      .img {
        width: 100%;
        height: 300px;
      }

      .title {
        line-height: 1;
        margin-top: 40px;
        font-size: 22px;
        font-weight: bold;
      }
    }
  }
}
</style>
